import React, {Component} from 'react'
import {View,Text, StyleSheet, ActivityIndicator,} from 'react-native'
import RootSiblings from 'react-native-root-siblings';
import {screen} from '../public/common';
let sibling = undefined

const Loading = {

  show: (text=false) => {
    sibling = new RootSiblings(
      <View style={styles.maskStyle}>
        <View style={styles.backViewStyle}>
          <ActivityIndicator size="large" color="white" />
          {text?<Text style={styles.ladingText}>{text}</Text>:null}
        </View>
      </View>
    )
  },

  hidden: ()=> {
    if (sibling instanceof RootSiblings) {
      sibling.destroy()
    }
  }

}

const styles = StyleSheet.create({
    maskStyle: {
      position: 'absolute',
      backgroundColor:'rgba(0, 0, 0, 0.3)',
      width: screen.width,
      height: screen.height,
      alignItems: 'center',
      justifyContent: 'center'
    },
    backViewStyle: {
      backgroundColor: '#111',
      width: 120,
      height: 100,
      justifyContent: 'center',
      alignItems: 'center',
      borderRadius: 5,
    },
    ladingText:{
        color:'#fff',
        marginTop: 10,
    }
  }
)

export {Loading};

// import {Loading} from './Loading';
// Loading.show('加载中')
// Loading.hidden()